package com.lxh.lxhcrm.model.pojos;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 联系人表
 */
@Entity
public class Contact {
    private int contactId;
    private String contactName;
    private Integer contactSex;//1男 2 女
    private Integer higherContact;
    private String position;
    private Integer colorIdentity;
    private String contactPhone;
    private String contactTel;
    private String contactAddress;
    private String emailAddress;
    private Date anniversary;
    private String detail;
    private String contactLable;
   // private int contactType;
    ContactType contactType;


    private Integer contactAge;
    private  Integer is_main;
    private Customer customer;
    /*//联系人对员工行动记录 一对多（业务员在行动中联系客户某位联系人）*/
    private List<ActionRecord> actionRecList;


    @Id
    @Column(name = "contact_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getContactId() {
        return contactId;
    }
    public void setContactId(int contactId) {
        this.contactId = contactId;
    }

    @ManyToOne
    @JoinColumn(name = "contact_type")
    public ContactType getContactType() {
        return contactType;
    }

    public void setContactType(ContactType contactType) {
        this.contactType = contactType;
    }
    @OneToMany(mappedBy = "contact")
    public List<ActionRecord> getActionRecList() {
        return actionRecList;
    }
    public void setActionRecList(List<ActionRecord> actionRecList) {
        this.actionRecList = actionRecList;
    }

    @Basic
    @Column(name = "is_main", nullable = true)
    public Integer getIs_main() {
        return is_main;
    }
    public void setIs_main(Integer is_main) {
        this.is_main = is_main;
    }
    @Basic
    @Column(name = "contact_name", nullable = true, length = 20)
    public String getContactName() {
        return contactName;
    }
    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    @Basic
    @Column(name = "contact_sex", nullable = true)
    public Integer getContactSex() {
        return contactSex;
    }

    public void setContactSex(Integer contactSex) {
        this.contactSex = contactSex;
    }

    @ManyToOne(optional = false)
    @JoinColumn(name = "customer_id")
    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    @Basic
    @Column(name = "higher_contact", nullable = true)
    public Integer getHigherContact() {
        return higherContact;
    }

    public void setHigherContact(Integer higherContact) {
        this.higherContact = higherContact;
    }

    @Basic
    @Column(name = "position", nullable = true, length = 20)
    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    @Basic
    @Column(name = "color_identity", nullable = true)
    public Integer getColorIdentity() {
        return colorIdentity;
    }

    public void setColorIdentity(Integer colorIdentity) {
        this.colorIdentity = colorIdentity;
    }

    @Basic
    @Column(name = "contact_phone", nullable = true, length = 10)
    public String getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }

    @Basic
    @Column(name = "contact_tel", nullable = true, length = 10)
    public String getContactTel() {
        return contactTel;
    }

    public void setContactTel(String contactTel) {
        this.contactTel = contactTel;
    }

    @Basic
    @Column(name = "contact_address", nullable = true, length = 200)
    public String getContactAddress() {
        return contactAddress;
    }

    public void setContactAddress(String contactAddress) {
        this.contactAddress = contactAddress;
    }

    @Basic
    @Column(name = "email_address", nullable = true, length = 100)
    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    @Basic
    @Column(name = "anniversary", nullable = true)
    public Date getAnniversary() {
        return anniversary;
    }

    public void setAnniversary(Date anniversary) {
        this.anniversary = anniversary;
    }

    @Basic
    @Column(name = "detail", nullable = true, length = 200)
    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    @Basic
    @Column(name = "contact_lable", nullable = true, length = 50)
    public String getContactLable() {
        return contactLable;
    }

    public void setContactLable(String contactLable) {
        this.contactLable = contactLable;
    }


    @Basic
    @Column(name = "contact_age", nullable = true)
    public Integer getContactAge() {
        return contactAge;
    }

    public void setContactAge(Integer contactAge) {
        this.contactAge = contactAge;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Contact contact = (Contact) o;
        return contactId == contact.contactId &&
                Objects.equals(contactName, contact.contactName) &&
                Objects.equals(contactSex, contact.contactSex) &&
                Objects.equals(higherContact, contact.higherContact) &&
                Objects.equals(position, contact.position) &&
                Objects.equals(colorIdentity, contact.colorIdentity) &&
                Objects.equals(contactPhone, contact.contactPhone) &&
                Objects.equals(contactTel, contact.contactTel) &&
                Objects.equals(contactAddress, contact.contactAddress) &&
                Objects.equals(emailAddress, contact.emailAddress) &&
                Objects.equals(anniversary, contact.anniversary) &&
                Objects.equals(detail, contact.detail) &&
                Objects.equals(contactLable, contact.contactLable) &&
                Objects.equals(contactType, contact.contactType) &&
                Objects.equals(contactAge, contact.contactAge) &&
                Objects.equals(is_main, contact.is_main) &&
                Objects.equals(customer, contact.customer) &&
                Objects.equals(actionRecList, contact.actionRecList);
    }

    @Override
    public int hashCode() {
        return Objects.hash(contactId, contactName, contactSex, higherContact, position, colorIdentity, contactPhone, contactTel, contactAddress, emailAddress, anniversary, detail, contactLable, contactType, contactAge, is_main, customer, actionRecList);
    }
}
